package com.wendy.dynamic.api;

import com.github.pagehelper.PageHelper;
import com.wendy.common.core.api.PageInterceptorApi;
import com.wendy.common.core.page.PageBO;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

@Component
@Primary
public class PageHelperInterceptorImpl implements PageInterceptorApi {
    private String name = "PageHelper";

    public PageHelperInterceptorImpl() {
    }

    @Override
    public boolean startPage(PageBO bo) {
        PageHelper.startPage(bo.getPageNum(), bo.getPageSize(), bo.getOrderByColumn()).setReasonable(bo.getReasonable());
        return true;
    }

    @Override
    public boolean removePage() {
        PageHelper.clearPage();
        return true;
    }
}
